﻿using IBLL;
using IBLL.Dto;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace Week3.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RoomTypeController : ControllerBase
    {
        public RoomTypeController(IRoomTypeBLL bLL)
        {
            BLL = bLL;
        }

        public IRoomTypeBLL BLL { get; }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="t">参数</param>
        /// <returns>返回</returns>
        [HttpPost]
        public Task<int> AddAsync(RoomType t)
        {
            return BLL.AddAsync(t);
        }
        /// <summary>
        /// 逻辑删除
        /// </summary>
        /// <param name="id">编号</param>
        /// <returns>返回</returns>
        [HttpDelete]
        public Task<int> DeleteLogiceAsync(int id)
        {
           return BLL.DeleteLogiceAsync(id);
        }
        /// <summary>
        /// 查全部
        /// </summary>
        /// <returns>返回</returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public IQueryable<RoomType> GetRoomsAll()
        {
            return BLL.GetRoomsAll();
        }
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="index">当前页</param>
        /// <param name="size">总条数</param>
        /// <param name="name">名称</param>
        /// <returns>返回</returns>
        [HttpGet]
        public RoomTypePageDto GetRoomTypePage(int index, int size, string? name)
        {
            return BLL.GetRoomTypePage(index, size, name);
        }
    }
}
